package com.longge;

import java.util.Arrays;

public class MinimumRemoval {

    public long minimumRemoval(int[] beans) {

        Arrays.sort(beans);

        long res = Long.MAX_VALUE;
        long sum = 0;

        for (int bean : beans) {
            sum += bean;
        }

        for (int i = 0; i < beans.length; i++) {
            res = Math.min(sum - (long)beans[i] * (beans.length - i), res);

        }
        return res;

    }
}
